package cn.white.ymc.mvvmmaster.data.local.db;

import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.content.Context;

/**
 * 创建 db 数据库
 *
 * @packageName: cn.white.ymc.mvvmmaster.data.local.db
 * @fileName: DBHelper
 * @date: 2018/11/6  11:04
 * @author: ymc
 * @QQ:745612618
 */

public class DBHelper {

    private static final DBHelper instance = new DBHelper();
    private static final String DATABASE_NAME = "c_cache";
    private DataBase dataBase;

    public static DBHelper getInstance(){
        return instance;
    }

    public void initDB(Context context){
        // room 禁止主线程访问数据库
        dataBase = Room.databaseBuilder(context,DataBase.class,DATABASE_NAME).build();
    }

    public DataBase getDB(){
        return dataBase;
    }

}
